package com.example.newnoke.ui;

import android.app.Activity;
import android.content.ClipboardManager;
import android.content.Context;
import android.webkit.JavascriptInterface;

import com.example.newnoke.APP;
import com.example.newnoke.utils.GsonUtil;
import com.geya.jbase.uiview.ToastUtil;
import com.just.agentweb.AgentWeb;

/**
 * Created by Administrator on 2018/6/20 0020.
 */

public class AndroidInterface {

    private Activity mContext;
    private AgentWeb mAgentWeb;

    private String id = "";
    private String type = "";
    private onChangeScreenMode mOnChangeScreenMode;

    public void setType(String type) {
        this.type = type;
    }

    public void setId(String dtxqID) {
        this.id = dtxqID;
    }

    public AndroidInterface(Activity context, AgentWeb agentWeb) {
        mContext = context;
        mAgentWeb = agentWeb;
    }

    public interface onChangeScreenMode{

        void changeScreenMode(String json);
    }


    public void setOnChangeScreenMode(onChangeScreenMode onChangeScreenMode) {
        mOnChangeScreenMode = onChangeScreenMode;
    }

    //获取用户信息
    @JavascriptInterface
    public String getUserInfo() {
        return GsonUtil.GsonString(APP.getUesrInfo());
    }

    @JavascriptInterface
    public String getID() {
        return id;
    }

    @JavascriptInterface
    public String getInfo() {
        return id;
    }
    @JavascriptInterface
    public void copy(String url) {
        ClipboardManager cm = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
        // 将文本内容放到系统剪贴板里。
        cm.setText(url);
        ToastUtil.showShort("复制成功，可以分享给朋友们了。");
    }




}
